package com.liu.stockmarket.ui.datacenter

import android.content.Context
import android.os.Bundle
import androidx.core.os.bundleOf
import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.snackbar.Snackbar
import com.google.android.material.tabs.TabLayout
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayoutMediator
import com.liu.stockmarket.BaseActivity
import com.liu.stockmarket.R
import com.liu.stockmarket.databinding.ActivityDataCenterBinding
import com.liu.stockmarket.utils.start

class DataCenterActivity : BaseActivity() {

    private lateinit var binding: ActivityDataCenterBinding
    private val tabTitles = arrayOf(
        "可转债",
        "行业板块"
    )
    private val tabIcon = arrayOf(
        R.drawable.ic_baseline_bond_24,
        R.drawable.ic_baseline_hot_24,
    )


    override fun initView(savedInstanceState: Bundle?) {
        binding = ActivityDataCenterBinding.inflate(layoutInflater)
        setContentView(binding.root)
        setToolbar(binding.toolbar.toolbar, addToolbarHeight = false)

        val sectionsPagerAdapter = SectionsPagerAdapter(this)
        val viewPager: ViewPager2 = binding.viewPager
        viewPager.isUserInputEnabled = false

        viewPager.adapter = sectionsPagerAdapter
        val tabs: TabLayout = binding.tabs

        TabLayoutMediator(tabs, viewPager, true) { tab, i ->
            tab.text = tabTitles[i]
            tab.setIcon(tabIcon[i])

        }.attach()



        val fab: FloatingActionButton = binding.fab

        fab.setOnClickListener { view ->
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null).show()
        }
    }

    override fun listener() {


    }

    override fun observer() {
    }

    companion object {
        fun start(context: Context) {
            context.start(bundleOf(), DataCenterActivity::class.java)
        }
    }
}